home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 6.8 KB | 164 lines | [TEXT/KAHL] |
- The PixelWorld Class
- --------------------
- Version 1.2
-
- SUPERCLASS = CBitMap
-
-
- 1) Description
-
- The CPixelWorld class is a subclass of CBitMap designed to maintain a
- color offscreen drawing environment using the standard conventions of
- Color QuickDraw. An offscreen color graphics device (GDevice) and an
- offscreen color graphics port (CGrafPort) are used to maintain this
- offscreen world. This implementation supports 1,2,4 and 8 bit pixel
- depths. Pixel depths of 16 and 32 bits are currently not supported.
-
- This implementation does not depend upon any 32-Bit QuickDraw features.
- Future versions of the CPixelWorld class will provide support for pixel
- depths of 16 and 32 bits, and for GWorlds under 32-Bit QuickDraw.
-
-
- 2) Creating a blank PixelWorld
-
- A blank pixel world is created by calling the initialization method
- IPixelWorld with a pixel depth (aPixelDepth), a bounds rectangle
- (aBoundsRect), a handle to a color table (aColorTable), and NULL for
- the handle to the pixel image (aPixelImage). You can pass any value
- for row bytes (aRowBytes) since the value will be ignored in this case.
- You should pass a color table handle (CTabHandle) in the aColorTable
- parameter. The color table is copied and the copy is used for the
- offscreen world. If aColorTable is NULL, then the default color table
- for the desired pixel depth will be used.
-
- *** WARNING ***
-
- If you request a pixel depth of one and Color QuickDraw is not
- available, then a blank offscreen world will be created as a standard
- BitMap with a non-color graphics port (GrafPort) using the CBitMap
- superclass. If you request a pixel depth greater than one and Color
- QuickDraw is not available, the initialization method will fail. To
- detect initialization failure call the method WorldIsOK, which
- returns the value of the instance variable worldIsOK. WorldIsOK
- will return TRUE after successful initialization, and FALSE after
- initialization failure.
-
-
- 3) Using an existing image to create a PixelWorld
-
- A world based on an existing color or grayscale image is created by
- calling the initialization method IPixelWorld with the pixel depth of
- the existing image (aPixelDepth), the bounds rectangle of the existing
- image (aBoundsRect), a color table for the existing image (aColorTable),
- and a handle to the pixels for the existing image (aPixelImage). In
- this case, you must also pass a value for the row bytes of the pixel
- image (aRowBytes).
-
- *** IMPORTANT ***
-
- When you create an offscreen world based on an existing pixel image,
- IT IS YOUR RESPONSIBILITY TO DISPOSE OF YOUR PIXEL IMAGE. Although
- CPixelWorld keeps its own handle to your pixel image in the instance
- variable worldPixels, it will not dispose of the pixel image. In
- contrast, when you create a blank world by passing NULL for the
- aPixelImage parameter, CPixelWorld creates its own pixel image and it
- will dispose of this image when the offscreen world is destroyed by
- the Dispose method.
-
- When you create your own pixel image for use with an offscreen world
- use a multiple of four for the row bytes of your pixel image. The
- following formula will give a multiple of four for row bytes:
-
- rowBytes = ((((long) width * pixelDepth) + 31) / 32) * 4;
-
- A multiple of four for row bytes will give optimal performance in calls
- to the QuickDraw function CopyBits and its related functions.
-
- *** WARNING ***
-
- When you create an offscreen world with an existing image that has a
- pixel depth greater than one, the initialization method will fail if
- Color QuickDraw is not available since there is no support for images
- with pixel depths greater than one without Color QuickDraw.
-
-
- 4) Drawing to a PixelWorld
-
- If you need to draw directly to the offscreen world, you must bracket
- all drawing with calls to BeginDrawing and EndDrawing. This will
- set up the offscreen GDevice and CGrafPort for drawing. The PixelWorld
- will be sent a LockWorld( TRUE) message to make sure that the pixel
- image is anchored down and will not move when you invoke any QuickDraw
- routines. LockWorld( TRUE) locks the handle to the pixel image, and
- then loads the derefernced handle into the PixMap baseAddr pointers of
- both the offscreen GDevice and the offscreen CGrafPort.
-
-
- 5) History
-
- • Version 1.0
-
- Date: January 1, 1992
- Author: Vincent R. Vann, Jr.
- Address: 1901 Brickell Ave, B-410, Miami, FL 33129 (USA)
- Internet: vvann@umbio.med.miami.edu
- Compuserve: 76530,1242
-
- • Version 1.1
-
- Date: January 28, 1992
- Modified By: Vincent R. Vann, Jr.
-
- Changes:
- [
- - CopyFrom and CopyTo methods were modified so that the foreground
- and background colors are set to black and white before calling
- CopyBits. This ensures that the PixelWorld image is copied with
- the proper colors. The foreground and background colors of the
- current CGrafPort are preserved by these methods.
- ]
-
- • Version 1.2
-
- Date: June 15, 1992
- Modified By: Vincent R. Vann, Jr.
-
- Changes:
- [
- - added new instance variables saveFgColor and saveBgColor.
- - implemented new methods SaveColors, RestoreColors,
- CopyFromColors, and CopyToColors.
- - changed CopyFrom and CopyTo methods to use these color routines.
- - see comments for CopyFromColors and CopyToColors for information
- about how to colorize your image.
- ]
-
-
- 6) License Agreement
-
- All portions of this source code are property of Vincent R. Vann, Jr.
- I, Vincent R. Vann, Jr., grant you the right to freely distribute this
- source code and to use all or part of this source code in all software
- including commercial, freeware, shareware and private applications.
- However, all software that uses any part of or all of this source code
- must display a copyright notice indicating that either all of or
- portions of this source code are used in the software. I also grant
- you permission to alter and make improvements to this source code, but
- only if all modifications are returned to me by whatever means are
- available, either in written or electronic form. You must also accept
- that I retain the right to include any part of your modifications or
- all of your modifications in future releases of this source code. The
- description and version history sections of the *.info files may be
- ammended for documentation purposes. This license agreement and the
- copyright notice below must be maintained intact and must be included
- with all distributions of this source code at all times.
-
-
- 7) Copyright Notice
-
- This implementation is based in part on material copyrighted by
- Symantec Corporation and Apple Computer, Inc.
-
- Copyright © 1992 Vincent R. Vann, Jr. All rights reserved.
-
-